package com.prs.crm.action.receipt;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.domain.receipt.ReceiptPoint;
import com.prs.crm.service.receipt.ReceiptPointService;

public class ReceiptPointAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private ReceiptPoint receiptPoint;
	private ReceiptPointService	receiptPointService;
	private PaginationSupport pagination;
	private Integer[] ids;
	public ReceiptPoint getReceiptPoint() {
		return receiptPoint;
	}
	public void setReceiptPoint(ReceiptPoint receiptPoint) {
		this.receiptPoint = receiptPoint;
	}
	public ReceiptPointService getReceiptPointService() {
		return receiptPointService;
	}
	public void setReceiptPointService(ReceiptPointService receiptPointService) {
		this.receiptPointService = receiptPointService;
	}
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	public Integer[] getIds() {
		return ids;
	}
	public void setIds(Integer[] ids) {
		this.ids = ids;
	}
	
	@Action("listReceiptPoint")
	public String listReceiptPoint(){
		DetachedCriteria criteria=this.getPaginationHelper().createQuery(ReceiptPoint.class);
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getReceiptPointService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	
	@Action("editReceiptPoint")
	public String editReceiptPoint(){
		return SUCCESS;
	}
	
	@Action(value="saveReceiptPoint",results={
			@Result(name="success",type="redirect",location="listReceiptPoint"),
			@Result(name="error",type="chain",location="editReceiptPoint")
	})
	public String saveReceiptPoint(){
		this.getReceiptPointService().save(receiptPoint);
		return SUCCESS;
	}
	
	@Action(value="removeReceiptPoint",results={
			@Result(name="success",type="redirect",location="listReceiptPoint"),
			@Result(name="error",type="chain",location="listReceiptPoint")
	})
	public String removeReceiptPoint(){
		this.getReceiptPointService().batchRemove(ids);
		return SUCCESS;
	}
}
